﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace OaEntity.Models;

public partial class OaContext : DbContext
{
    public OaContext()
    {
    }

    public OaContext(DbContextOptions<OaContext> options)
        : base(options)
    {
    }

    public virtual DbSet<Tcauser> Tcausers { get; set; }

    public virtual DbSet<To2student> To2students { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder.UseSqlServer("Server=127.0.0.1;Database=CommonData;user id=sa;password=root;TrustServerCertificate=true;MultipleActiveResultSets=true");

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Tcauser>(entity =>
        {
            entity.HasKey(e => e.UserId).HasName("PK__TCAUsers__1788CCACA2DAB955");

            entity.ToTable("TCAUsers");

            entity.HasIndex(e => e.UserName, "UQ__TCAUsers__C9F284561B2072A2").IsUnique();

            entity.Property(e => e.UserId).HasColumnName("UserID");
            entity.Property(e => e.Email).HasMaxLength(100);
            entity.Property(e => e.IsDelete).HasDefaultValue(false);
            entity.Property(e => e.OperateTime)
                .HasDefaultValueSql("(getdate())")
                .HasColumnType("datetime");
            entity.Property(e => e.Operater).HasDefaultValueSql("('1')");
            entity.Property(e => e.Password).HasMaxLength(256);
            entity.Property(e => e.Phone).HasMaxLength(100);
            entity.Property(e => e.Status).HasDefaultValue(1);
            entity.Property(e => e.UserName).HasMaxLength(256);
        });

        modelBuilder.Entity<To2student>(entity =>
        {
            entity.HasKey(e => e.StudentId).HasName("PK__TO2Stude__32C52A79F776BD54");

            entity.ToTable("TO2Students");

            entity.Property(e => e.StudentId).HasColumnName("StudentID");
            entity.Property(e => e.City).HasMaxLength(200);
            entity.Property(e => e.Country).HasMaxLength(50);
            entity.Property(e => e.Province).HasMaxLength(50);
            entity.Property(e => e.StudentAddress).HasMaxLength(200);
            entity.Property(e => e.StudentName).HasMaxLength(50);
            entity.Property(e => e.StudentPhoneNumber).HasMaxLength(20);
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
